<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="陈嘉乐">
    <title></title>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
        }

        header {
            height: 50px;
            border-bottom: 2px solid #D0CAC9;
        }

        ul {
            display: flex;
            list-style: none;
            float: right;
            border-right: 1px solid #D0CAC9;
            position: relative;
        
        }

        ul>li {
              
                margin: 5px;
                
        }
        ul>li>a{
            color: black;
            font-size: 18px;
        }
        .foot>li>a{
            font-weight: bold;
        }
        .head {
            width: 350px;
            border-right: 0;
            margin-right: 300px;
            line-height: 25px;
          
        }
        .clear{
            clear: both;
        }
        .container{
             margin: 100px 600px;
        }
        .container>img{
            width: 150px;
            height: 45px;
             border: 0;

        }
        .container>.current{
            width: 300px;
            height: 40px;
        padding-top: 3px;
        }
        .container>.active{
            width: 100px;
            height: 40px;
             margin-left: -5px;  
             background-color: #3388FF;
             border: 0;        
        }
        .name{
            margin-top: -30px;
        }
        .name>li>a{
        
     
    font-size: 15px;
    line-height: 18px;
        }
        .btn{
            margin-left: 750px;
            margin-top: -100px;
        }
     nav{
         width: 100%;
        background-color: #01204F;
         height: 50px;
      
       
     }
     nav>ul{
         width: 1000px;
      float: left;
      margin-left: 500px;
      border-right: 0;
      margin-top: -5px;
     }
     nav li{
          height: 50px; 
         line-height: 50px;
         
    
     }
     nav>ul>li{
       font-size: 15px;
       color: white;
         font-weight: bold;
     }
     section{
         height: 2000px;
     }
     .color{
         color: white;
    background-color:red;
}
section button{
  width: 100px;
  height: 100px;
}
    </style>
</head>

<body>
    <header>
        <ul class="head">
            <li><a href="">百度首页</a></li>
            <li><a href="">登录</a></li>
            <li><a href="">注册</a></li>
            <li><a href="">百度新闻客户端</a></li>
        </ul>
        <ul class="foot">
            <li><a href="">网页</a></li>
            <li><a href="">新闻</a></li>
            <li><a href="">贴吧</a></li>
            <li><a href="">知道</a></li>
            <li><a href="">音乐</a></li>
            <li><a href="">图片</a></li>
            <li><a href="">视频</a></li>
            <li><a href="">地图</a></li>
            <li><a href="">文库</a></li>
        </ul>
        <div class="clear"></div>
    </header>
    <div class="container">
        <img src="1.png" alt="">
    <input type="text"   class="current"  >
    <input type="button"  class="active" value="百度一下">
    <ul class="name">
        <li><a href="">帮助</a></li>
        <li><a href="">搜索</a></li>
        <li><a href="">高级设置</a></li>
    </ul>
    </div>

 <p class="btn">
     <input type="radio" name="tn"  checked >新闻全文
     <!-- <label for="news" class="checked">新闻全文</label> -->
     <input type="radio" name="tn"   >新闻标题
     <!-- <label for="news" class="checked">新闻标题</label> -->
 </p>
    <nav>
        <ul class="list">
            <li class="color">首页</li>
            <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
           <li>首页</li>
        </ul>
    </nav>
    <section>
       <button type="button" onclick="newClick(event)">&#8593</button>
    </section>
</body>
</html>
<script>
    var nav = document.querySelector('nav');
window.onscroll = function () {
    var scrollTop = document.scrollingElement.scrollTop;
  
    if (scrollTop>100) {
   nav.style.position = 'fixed';
     nav.style.top ='0';
    }else{
        nav.style.cssText='';
    }
}

var lis = document.querySelectorAll('.list li');
var  list = document.querySelector('.list');

// for (var i = 0; i < lis.length; i++) {
//   lis[i].index = i;
//   lis[i].onmousover = function (ev) {
//       for (var i = 0; i < lis.length; i++) {
//           lis[i].className = '';
//       }
//       this.className= 'color';
//                 strong.innerHTML = this.index+1;
//                 // li.innerHTML = lis[this.index];
//   }
    
// }
 var lastIndex = 0;
        for (var i = 0; i < lis.length; i++) {
            lis[i].index = i;
            lis[i].onmouseover = function (ev) {
             
                lis[lastIndex].className = '';
              lis[0].className = 'color';
                this.className = 'color';

            }
            lis[i].onmouseout = function () {
              
                lastIndex = this.index;

            }
        }


    
</script>